package com.mallotec.android.timenote.ui.common;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import com.mallotec.android.timenote.databinding.ActivityMainBinding;

/**
 * @program TimeNote
 * @description Activity 的 base 抽象类
 * @author reborn
 * @create 2020-10-14 21:45
 **/
public abstract class BaseActivity<VB extends ViewDataBinding> extends AppCompatActivity {

    protected VB binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, getLayoutId());
        onInitView(savedInstanceState);
        onInit(savedInstanceState);
    }

    /**
     * 获取布局 id
     * @return 布局 id
     */
    protected abstract int getLayoutId();

    /**
     * 初始化 view
     * 比 onInit 早执行
     *
     * @param savedInstanceState 保存的 Bundle
     */
    protected abstract void onInitView(Bundle savedInstanceState);

    /**
     * 初始化
     *
     * @param savedInstanceState 保存的 Bundle
     */
    protected abstract void onInit(Bundle savedInstanceState);
}
